package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.ProjectQueryParamDto;
import com.zzyl.serve.domain.NursingProject;
import com.zzyl.serve.service.INursingProjectService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/member/orders")
public class OrdersController extends BaseController {

    @Autowired
    private INursingProjectService nursingProjectService;

    /**
     * 获取护理项目列表
     * @param projectQueryParamDto
     * @return
     */
    @GetMapping("/project/page")
    @ApiOperation("获取护理项目列表")
    public TableDataInfo<List<NursingProject>> list(ProjectQueryParamDto projectQueryParamDto) {
        log.info("小程序护理项目分页显示参数:{}", projectQueryParamDto);
        NursingProject nursingProject = new NursingProject();
        BeanUtils.copyProperties(projectQueryParamDto, nursingProject);
        startPage();
        List<NursingProject> list = nursingProjectService.selectNursingProjectList(nursingProject);
        return getDataTable(list);
    }

    @GetMapping("/project/{id}")
    @ApiOperation("获取护理项目详情")
    public AjaxResult detail(@PathVariable Long id) {
        NursingProject nursingProject = nursingProjectService.selectNursingProjectById(id);
        return success(nursingProject);
    }
}
